package com.dao.imp;

import com.entity.User;
import com.util.DBConn;

import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * @author Mathison
 * @Title: FindUser
 * @Package: com.dao.imp
 * @Description: TODO
 * @date 2021/11/26 15:07
 **/
public class FindUser {
    public static User findUser(String sql){
        User user = new User();
        try{
            DBConn.init();
            ResultSet resultSet = DBConn.selectSql(sql);
            while (resultSet.next()){
                user.setUser_id(resultSet.getInt("user_id"));
                user.setUser_email(resultSet.getString("user_email"));
                user.setUser_phone(resultSet.getString("user_phone"));
                user.setUser_nickname(resultSet.getString("user_nickname"));
                user.setUser_password(resultSet.getString("user_password"));
            }
//            DBConn.closeConn();
        }catch (SQLException e){
            e.printStackTrace();
        }
        return user;
    }
}
